var Url = { 
        // public method for url encoding 
        encode : function (string) { 
                return escape(this._utf8_encode(string)); 
        }, 
        // public method for url decoding 
        decode : function (string) { 
                return this._utf8_decode(unescape(string)); 
        }, 
        // private method for UTF-8 encoding 
        _utf8_encode : function (string) { 
                string = string.replace(/\r\n/g,"\n"); 
                var utftext = ""; 
                for (var n = 0; n < string.length; n++) { 
                        var c = string.charCodeAt(n); 
                        if (c < 128) { 
                                utftext += String.fromCharCode(c); 
                        } 
                        else if((c > 127) && (c < 2048)) { 
                                utftext += String.fromCharCode((c >> 6) | 192); 
                                utftext += String.fromCharCode((c & 63) | 128); 
                        } 
                        else { 
                                utftext += String.fromCharCode((c >> 12) | 224); 
                                utftext += String.fromCharCode(((c >> 6) & 63) | 128); 
                                utftext += String.fromCharCode((c & 63) | 128); 
                        } 
                } 
                return utftext; 
        }, 
        // private method for UTF-8 decoding 
        _utf8_decode : function (utftext) { 
                var string = ""; 
                var i = 0; 
                var c = c1 = c2 = 0; 
                while ( i < utftext.length ) { 
                        c = utftext.charCodeAt(i); 
                        if (c < 128) { 
                                string += String.fromCharCode(c); 
                                i++; 
                        } 
                        else if((c > 191) && (c < 224)) { 
                                c2 = utftext.charCodeAt(i+1); 
                                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 
                                i += 2; 
                        } 
                        else { 
                                c2 = utftext.charCodeAt(i+1); 
                                c3 = utftext.charCodeAt(i+2); 
                                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 
                                i += 3; 
                        } 
                } 
                return string; 
        } 
}
jQuery(document).ready(function() {
    var relocation_type=geturlparameter('relocation_type');
    var relocation_effective_date=geturlparameter('relocation_effective_date');
    var sending_work_location_site=geturlparameter('sending_work_location_site');
    var sending_work_city=geturlparameter('sending_work_city');
    var please_specify_sending=geturlparameter('please_specify_sending');
    var receiving_work_location_site=geturlparameter('receiving_work_location_site');
    var receiving_work_city=geturlparameter('receiving_work_city');
    var please_specify_receiving=geturlparameter('please_specify_receiving');
    var receiving_company_legal_entity2=geturlparameter('receiving_company_legal_entity2');
    var receiving_cost_centre=geturlparameter('receiving_cost_centre');
    var title=geturlparameter('title');
    var employee_first_name=geturlparameter('employee_first_name');
    var employee_last_name=geturlparameter('employee_last_name');
    var global_sap_id=geturlparameter('global_sap_id');
    var email_address=Url.decode(geturlparameter('email_address'));
    var email_address_2=Url.decode(geturlparameter('email_address_2'));
    var phone_work=geturlparameter('phone_work');
    var mobile_work=geturlparameter('mobile_work');
    var str_function=geturlparameter('function');
    var if_cbd_please_provide_long_term_career_base=geturlparameter('if_cbd_please_provide_long_term_career_base');
    var salary_change_date=geturlparameter('salary_change_date');
    var is_the_spouse_partner_a_pg_employee=geturlparameter('is_the_spouse_partner_a_pg_employee');
    var if_yes_please_provide_spouse_partners_full_name=geturlparameter('if_yes_please_provide_spouse_partners_full_name');
    var is_spouse_partner_also_being_transferred=geturlparameter('is_spouse_partner_also_being_transferred');
    var spouse_partners_sap_id_personnel_number=geturlparameter('spouse_partners_sap_id_personnel_number');
    var relocation_initiator_role=geturlparameter('relocation_initiator_role');
    var initiator_last_name=geturlparameter('initiator_last_name');
    var initiator_first_name=geturlparameter('initiator_first_name');
    var initiator_email=Url.decode(geturlparameter('initiator_email'));
    var relocation_initiator_phone_=geturlparameter('relocation_initiator_phone_');
    var name_of_receiving_line_manager=Url.decode(geturlparameter('name_of_receiving_line_manager'));
    var receiving_line_manager_email=geturlparameter('receiving_line_manager_email');
    var name_of_receiving_hr_manager=geturlparameter('name_of_receiving_hr_manager');
    var receiving_hr_manager_email=geturlparameter('receiving_hr_manager_email');
    var receiving_hr_manager_phone=geturlparameter('receiving_hr_manager_phone');
    var not_rlm_confirm_info=geturlparameter('not_rlm_confirm_info');
    
    var relocation_type_key = new Array();
    relocation_type_key['Local-to-Local Permanent Relocation']='cn_local-to-local_permanent_relocation';
    relocation_type_key['Temporary Relocation']='cn_temporary_relocation';
    relocation_type_key['Local Extended Business Travel']='cn_local_extended_business_travel';
    relocation_type_key['FPE Domestic Relocation']='cn_fpe_domestic_relocation';
    relocation_type_key['Returning to Home Company / Home Base']='cn_returning_to_home_company_home_base';
    relocation_type_key['Personal Request Temporary Transfer']='cn_personal_request_temporary_transfer';
    relocation_type_key['Termination while on Temporary Transfer']='cn_termination_while_on_temporary_transfer';
    relocation_type_key['Plant Technology Transfer and Training']='cn_plant_technology_transfer_and_training';
    var title_key = new Array();
    title_key['Miss']=1;
    title_key['Mrs']=2;
    title_key['Mr']=3;
    title_key['Dr']=4;
    var str_function_key = new Array();
    str_function_key['HR- AIR OPERATIONS']='cn_HR_AIR_OPERATIONS';
    str_function_key['CUSTOMER BUSINESS DEVELOPMENT - SALES']='cn_CUSTOMER_BUSINESS_DEVELOPMENT_SALES';
    str_function_key['CONSUMER MARKET KNOWLEDGE']='cn_CONSUMER_MARKET_KNOWLEDGE';
    str_function_key['COMMUNICATIONS']='cn_COMMUNICATIONS';
    str_function_key['PS - CUSTOMER SERVICE']='cn_PS_CUSTOMER_SERVICE';
    str_function_key['DESIGN']='cn_DESIGN';
    str_function_key['PS - ENGINEERING']='cn_PS_ENGINEERING';
    str_function_key['IDS - FACILITIES SERVICES']='cn_IDS_FACILITIES_SERVICES';
    str_function_key['FINANCE & ACCOUNTING']='cn_FINANCE_ACCOUNTING';
    str_function_key['LEGAL - GLOBL GOVERNMENT RELATIONS']='cn_LEGAL_GLOBL_GOVERNMENT_RELATIONS';
    str_function_key['GENERAL MANAGEMENT']='cn_GENERAL_MANAGEMENT';
    str_function_key['HR - HUMAN RESOURCES']='cn_HR_HUMAN_RESOURCES';
    str_function_key['PS - INNOVATION DIAMOND MANAGEMENT']='cn_PS_INNOVATION_DIAMOND_MANAGEMENT';
    str_function_key['IDS - INFORMATION & DECISION SOLUTIONS']='cn_IDS_INFORMATION_DECISION_SOLUTIONS';
    str_function_key['LEGAL - LEGAL']='cn_LEGAL_LEGAL';
    str_function_key['PS - MANUFACTURING']='cn_PS_MANUFACTURING';
    str_function_key['HR - MEDICAL']='cn_HR_MEDICAL';
    str_function_key['MARKETING']='cn_MARKETING';
    str_function_key['LEGAL - PATENT']='cn_LEGAL_PATENT';
    str_function_key['PS - CORPORATE']='cn_PS_CORPORATE';
    str_function_key['PS - PURCHASING']='cn_PS_PURCHASING';
    str_function_key['RESEARCH & DEVELOPMENT']='cn_RESEARCH_DEVELOPMENT';
    str_function_key['HR - SECURITY']='cn_HR_SECURITY';
    var relocation_initiator_role_key = new Array();
    relocation_initiator_role_key['HR']='HR';
    relocation_initiator_role_key['Sending Line Manager']='SLM';
    relocation_initiator_role_key['Receiving Line Manager']='RLM';
    relocation_initiator_role_key['Surrogate']='Surrogate';
    relocation_initiator_role_key['Talent Practice (Recruitment)']='TalentPractice';
    relocation_initiator_role_key['Other']='Other';
    if(relocation_type!=''){
        jQuery("#edit-submitted-relocation-data-relocation-type").val(relocation_type_key[Url.decode(relocation_type)]); 
    }
    if(geturlparameter('is_the_employee_a_new_hire')=='Yes'){
        jQuery("#edit-submitted-relocation-data-is-the-employee-a-new-hire-1").attr('checked','checked');
    }
    if(relocation_effective_date!=''){
        var day=parseInt(relocation_effective_date.split('-')[0]);
        var month=parseInt(relocation_effective_date.split('-')[1]);
        var year=relocation_effective_date.split('-')[2];
        jQuery("#edit-submitted-relocation-data-relocation-effective-date-day").val(day);
        jQuery("#edit-submitted-relocation-data-relocation-effective-date-month").val(month);
        jQuery("#edit-submitted-relocation-data-relocation-effective-date-year").val(year);
    }
    if(sending_work_location_site!=''){
        jQuery("#edit-submitted-relocation-data-sending-work-location-site").val(sending_work_location_site); 
    }
    if(sending_work_city!=''){
        jQuery("#edit-submitted-relocation-data-sending-work-city").val(sending_work_city); 
    }
    if(please_specify_sending!=''){
        jQuery("#edit-submitted-relocation-data-please-specify-sending").val(please_specify_sending); 
    }
    if(receiving_work_location_site!=''){
        jQuery("#edit-submitted-relocation-data-receiving-work-location-site").val(receiving_work_location_site); 
    }
    if(receiving_work_city!=''){
        jQuery("#edit-submitted-relocation-data-receiving-work-city").val(receiving_work_city); 
    }
    if(please_specify_receiving!=''){
        jQuery("#edit-submitted-relocation-data-please-specify-receiving").val(please_specify_receiving); 
    }
    if(please_specify_receiving!=''){
        jQuery("#edit-submitted-relocation-data-please-specify-receiving").val(please_specify_receiving); 
    }
    if(receiving_company_legal_entity2!=''){
        
    }
    if(receiving_cost_centre!=''){
        jQuery("#edit-submitted-relocation-data-receiving-cost-centre").val(receiving_cost_centre); 
    }
    if(title!=''){
        jQuery("#edit-submitted-personal-data-title").val(title_key[title]); 
    }
    if(employee_first_name!=''){
        jQuery("#edit-submitted-personal-data-employee-first-name").val(employee_first_name); 
    }
    if(employee_last_name!=''){
        jQuery("#edit-submitted-personal-data-employee-last-name").val(employee_last_name); 
    }
    if(global_sap_id!=''){
        jQuery("#edit-submitted-personal-data-global-sap-id").val(global_sap_id); 
    }
    if(email_address!=''){
        jQuery("#edit-submitted-personal-data-email-address").val(email_address); 
    }
    if(email_address_2!=''){
        jQuery("#edit-submitted-personal-data-email-address-2").val(email_address_2); 
    }
    if(phone_work!=''){
        jQuery("#edit-submitted-personal-data-phone-work-country").val(phone_work.split('|')[0]);
        jQuery("#edit-submitted-personal-data-phone-work-area").val(phone_work.split('|')[1]);
        jQuery("#edit-submitted-personal-data-phone-work-phone").val(phone_work.split('|')[2]);
        jQuery("#edit-submitted-personal-data-phone-work-ext").val(phone_work.split('|')[3]);
    }
    if(mobile_work!=''){
        jQuery("#edit-submitted-personal-data-mobile-work-country").val(mobile_work.split('|')[0]); 
        jQuery("#edit-submitted-personal-data-mobile-work-mobile").val(mobile_work.split('|')[1]); 
    }
    if(str_function!=''){
        jQuery("#edit-submitted-personal-data-function").val(str_function_key[Url.decode(str_function)]); 
    }
    if(if_cbd_please_provide_long_term_career_base!=''){
        jQuery("#edit-submitted-personal-data-if-cbd-please-provide-long-term-career-base").val(if_cbd_please_provide_long_term_career_base); 
    }
    if(salary_change_date!=''){
        var salary_change_date_day=parseInt(salary_change_date.split('-')[0]);
        var salary_change_date_month=parseInt(salary_change_date.split('-')[1]);
        var salary_change_date_year=salary_change_date.split('-')[2];
        jQuery("#edit-submitted-relocation-data-relocation-effective-date-day").val(salary_change_date_day);
        jQuery("#edit-submitted-relocation-data-relocation-effective-date-month").val(salary_change_date_month);
        jQuery("#edit-submitted-relocation-data-relocation-effective-date-year").val(salary_change_date_year);
    }
    if(is_the_spouse_partner_a_pg_employee=='Yes'){
        jQuery("#edit-submitted-for-allowances-calculation-is-the-spouse-partner-a-pg-employee-1").attr('checked','checked');
    }
    if(if_yes_please_provide_spouse_partners_full_name!=''){
        jQuery("#edit-submitted-for-allowances-calculation-if-yes-please-provide-spouse-partners-full-name").val(if_yes_please_provide_spouse_partners_full_name); 
    }
    if(is_spouse_partner_also_being_transferred=='Yes'){
        jQuery("#edit-submitted-for-allowances-calculation-is-spouse-partner-also-being-transferred-1").attr('checked','checked');
    }
    if(spouse_partners_sap_id_personnel_number!=''){
        jQuery("#edit-submitted-for-allowances-calculation-spouse-partners-sap-id-personnel-number").val(spouse_partners_sap_id_personnel_number); 
    }
    if(relocation_initiator_role!=''){
        jQuery("#edit-submitted-pg-initiator-approver-relocation-initiator-role").val(relocation_initiator_role_key[Url.decode(relocation_type)]); 
    }
    if(initiator_last_name!=''){
        jQuery("#edit-submitted-pg-initiator-approver-initiator-last-name").val(initiator_last_name); 
    }
    if(initiator_first_name!=''){
        jQuery("#edit-submitted-pg-initiator-approver-initiator-first-name").val(initiator_first_name); 
    }
    if(initiator_email!=''){
        jQuery("#edit-submitted-pg-initiator-approver-initiator-email").val(initiator_email); 
    }
    if(relocation_initiator_phone_!=''){
        jQuery("#edit-submitted-pg-initiator-approver-relocation-initiator-phone-country").val(relocation_initiator_phone_.split('|')[0]);
        jQuery("#edit-submitted-pg-initiator-approver-relocation-initiator-phone-area").val(relocation_initiator_phone_.split('|')[1]);
        jQuery("#edit-submitted-pg-initiator-approver-relocation-initiator-phone-phone").val(relocation_initiator_phone_.split('|')[2]);
        jQuery("#edit-submitted-pg-initiator-approver-relocation-initiator-phone-ext").val(relocation_initiator_phone_.split('|')[3]);
    }
    if(name_of_receiving_line_manager!=''){
        jQuery("#edit-submitted-pg-initiator-approver-name-of-approver").val(name_of_receiving_line_manager); 
    }
    if(receiving_line_manager_email!=''){
        jQuery("#edit-submitted-pg-initiator-approver-approver-email").val(receiving_line_manager_email); 
    }
    if(name_of_receiving_hr_manager!=''){
        jQuery("#dit-submitted-pg-initiator-approver-name-of-receiving-hr-manager").val(name_of_receiving_hr_manager); 
    }
    if(receiving_hr_manager_email!=''){
        jQuery("#edit-submitted-pg-initiator-approver-receiving-hr-manager-email").val(receiving_hr_manager_email); 
    }
    if(receiving_hr_manager_phone!=''){
        jQuery("#edit-submitted-pg-initiator-approver-receiving-hr-manager-phone-country").val(receiving_hr_manager_phone.split('|')[0]);
        jQuery("#edit-submitted-pg-initiator-approver-receiving-hr-manager-phone-area").val(receiving_hr_manager_phone.split('|')[1]);
        jQuery("#edit-submitted-pg-initiator-approver-receiving-hr-manager-phone-phone").val(receiving_hr_manager_phone.split('|')[2]);
        jQuery("#edit-submitted-pg-initiator-approver-receiving-hr-manager-phone-ext").val(receiving_hr_manager_phone.split('|')[3]);
    }
    if(not_rlm_confirm_info!=''){
        
    }
//    jQuery('#' + employee_last_name).addClass('english');
}) 